//
// CVegetableVBAllocator.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

public class CVegetableVBAllocator {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CVegetableVBAllocator(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CVegetableVBAllocator obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CVegetableVBAllocator(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CVegetableVBAllocator() {
    this(nel3dJNI.new_CVegetableVBAllocator(), true);
  }

  public void init(CVegetableVBAllocator.TVBType vbType, long maxVertexInBufferHard) {
    nel3dJNI.CVegetableVBAllocator_init(swigCPtr, this, vbType.swigValue(), maxVertexInBufferHard);
  }

  public void updateDriver(IDriver driver) {
    nel3dJNI.CVegetableVBAllocator_updateDriver(swigCPtr, this, IDriver.getCPtr(driver), driver);
  }

  public void clear() {
    nel3dJNI.CVegetableVBAllocator_clear(swigCPtr, this);
  }

  public boolean exceedMaxVertexInBufferHard(long numAddVerts) {
    return nel3dJNI.CVegetableVBAllocator_exceedMaxVertexInBufferHard(swigCPtr, this, numAddVerts);
  }

  public long getNumUserVerticesAllocated() {
    return nel3dJNI.CVegetableVBAllocator_getNumUserVerticesAllocated(swigCPtr, this);
  }

  public long allocateVertex() {
    return nel3dJNI.CVegetableVBAllocator_allocateVertex(swigCPtr, this);
  }

  public void deleteVertex(long vid) {
    nel3dJNI.CVegetableVBAllocator_deleteVertex(swigCPtr, this, vid);
  }

  public CVertexBuffer getSoftwareVertexBuffer() {
    return new CVertexBuffer(nel3dJNI.CVegetableVBAllocator_getSoftwareVertexBuffer__SWIG_0(swigCPtr, this), false);
  }

  public void flushVertex(long i) {
    nel3dJNI.CVegetableVBAllocator_flushVertex(swigCPtr, this, i);
  }

  public void lockBuffer() {
    nel3dJNI.CVegetableVBAllocator_lockBuffer(swigCPtr, this);
  }

  public void unlockBuffer() {
    nel3dJNI.CVegetableVBAllocator_unlockBuffer(swigCPtr, this);
  }

  public boolean bufferLocked() {
    return nel3dJNI.CVegetableVBAllocator_bufferLocked(swigCPtr, this);
  }

  public boolean isBGRA() {
    return nel3dJNI.CVegetableVBAllocator_isBGRA(swigCPtr, this);
  }

  public void activate() {
    nel3dJNI.CVegetableVBAllocator_activate(swigCPtr, this);
  }

  public final static class TVBType {
    public final static TVBType VBTypeLighted = new TVBType("VBTypeLighted", nel3dJNI.CVegetableVBAllocator_VBTypeLighted_get());
    public final static TVBType VBTypeUnlit = new TVBType("VBTypeUnlit");
    public final static TVBType VBTypeCount = new TVBType("VBTypeCount");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TVBType swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TVBType.class + " with value " + swigValue);
    }

    private TVBType(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TVBType(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TVBType(String swigName, TVBType swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TVBType[] swigValues = { VBTypeLighted, VBTypeUnlit, VBTypeCount };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
